

#ifndef STOREXSERVER_H_
#define STOREXSERVER_H_



#include <boost/array.hpp>
#include <boost/function.hpp>
#include "Connection.h"
#include <boost/make_shared.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/asio.hpp>
#include <boost/variant.hpp>
#include <vector>
#include <boost/thread.hpp>
#include "ConnectionTable.h"
#include "../Interface/StorexEngine.h"


class StorexServer {

public:

	StorexServer(int port, int thread_pool_size);

	void run();

	void stop();

	const static int DEFAULT_PORT= 50254;

private:

	// Handle completion of an asynchronous accept operation.
	void handle_accept(const boost::system::error_code& e);

	// The number of threads that will call io_service::run().
	std::size_t threadNum;

	// The io_service used to perform asynchronous operations.
	boost::asio::io_service ioService;

	// Acceptor used to listen for incoming connections.
	boost::asio::ip::tcp::acceptor acceptor;

	// The next connection to be accepted.
	boost::shared_ptr<Connection> newConnection;

	ConfigHandler* configHandler;
	StorexEngine storexEngine;

	int connectionCounter;
	ConnectionTable *connectionTable;

};

#endif /* STOREXSERVER_H_ */
